﻿using KinonekoSoftware.CodariaDB.Documents.DataParts.Modules.RVE;
using KinonekoSoftware.CodariaDB.Documents.Theories.Rarities;

namespace KinonekoSoftware.Studio.Models.Modules.RVE
{
    public sealed class RVEDashboardPresenter : RVE_Presenter<RVE_Dashboard>
    {

        public override string GetTitle() => string.IsNullOrEmpty(Title) ? CodariaSR.Module_RVE_Dashboard : Title;
        public override bool IsMultipleVariants() => false;
        public override IEnumerable<Variant> GetVariants(string documentID) => null;
        public override Variant GetVariant(string documentID)
        {
            return new IntegerVariant
            {
                Id    = documentID,
                Metadata = Metadata,
                Value = Value,
            };
        }

        public string Metadata
        {

            get
            {
                if (AssociatedObject is null)
                {
                    return string.Empty;
                }

                return AssociatedObject?.Metadata;
            }
            set
            {
                if (AssociatedObject is null)
                {
                    return;
                }

                AssociatedObject.Metadata = value;
                RaiseUpdated();
            }
        }

        public int Minimum
        {

            get
            {
                if (AssociatedObject is null)
                {
                    return 0;
                }

                return AssociatedObject.Minimum;
            }
            set
            {
                if (AssociatedObject is null)
                {
                    return;
                }

                AssociatedObject.Minimum = value;
                RaiseUpdated();
            }
        }

        public string Color
        {
            get => AssociatedObject?.Color ?? "#007ACC";
            set
            {
                if (AssociatedObject is null)
                {
                    return;
                }

                AssociatedObject.Color = value;
                RaiseUpdated();
            }
        }

        public int Maximum
        {
            get
            {
                if (AssociatedObject is null)
                {
                    return 10;
                }
                return AssociatedObject.Maximum;
            }
            set
            {
                if (AssociatedObject is null)
                {
                    return;
                }

                AssociatedObject.Maximum = value;
                RaiseUpdated();
            }
        }

        public int Value
        {
            get => AssociatedObject?.Value ?? 0;
            set
            {
                if (AssociatedObject is null)
                {
                    return;
                }

                AssociatedObject.Value = value;
                // OnValueChanged?.Invoke(Id, value);
                RaiseUpdated();
            }
        }
    }


}